package ec.edu.cec.java.adv.archivos;

import java.io.File;

public class GetSizeFileInBytes {

	public static long getFileSize(String fileName) {
		File file = new File(fileName);
		// The method "isFile" returns true if and only if the file denoted by
		// this
		// abstract pathname is a file else the method returns false.
		if (!file.exists() || !file.isFile()) {
			System.out.println("File doesn\'t exist");
			return -1;
		}
		return file.length();
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		long size = getFileSize("c:/test/demonstration.txt");
		System.out.println("File size in bytes: "+size);
	}

}
